<template>
  <div class="container">
    <div class="container_p">
      <div style="margin-bottom: 16px;"> 
        <img src="../assets/logo/log1o.png" style="width: 100px;" class="login-code-img"/>
        <div style="text-align: center;">
          <span style="font-size: 30px;">在線預約</span>
        </div>
      </div>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="客戶姓名" prop="customerName">
          <el-input v-model="form.customerName" placeholder="請輸入客戶姓名" />
        </el-form-item>
        <el-form-item label="聯繫方式" prop="telphone">
          <el-input v-model="form.telphone" placeholder="請輸入聯繫方式" />
        </el-form-item>
        <el-form-item label="電子郵箱" prop="email">
          <el-input v-model="form.email" placeholder="請輸入電子郵箱" />
        </el-form-item>
        <el-form-item label="預約事項" prop="matter">
          <el-select
            v-model="matter_list"
            multiple
            placeholder="請選擇預約事項"
            style="width: 100%"
          >
            <el-option
              v-for="dict in dict.type.business_scope"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="預約時間">
          <el-date-picker
            style="width: 100%"
            clearable
            v-model="form.reservationTime"
            type="datetime"
            @input="$forceUpdate()"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="請選擇預約時間"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="備註">
          <el-input
            type="textarea"
            :rows="2"
            v-model="form.content"
            placeholder="請輸入備註"
          />
        </el-form-item>
      </el-form>
      <div style="text-align: center">
        <el-button type="primary" :disabled="btn_disable" @click="submitForm">提 交</el-button>
        <el-button :disabled="btn_disable" @click="cancel">重 置</el-button>
      </div>
      <div class="el-login-footer">
      <span>© 2024 永力投資有限公司 版權所有</span>
    </div>
    </div>
  </div>
</template>

<script>
import { addReservationApply } from "@/api/biz/reservation";
export default {
  name: "Reservationpersonal",
  dicts: ["reservation_matter", "business_scope"],
  data() {
    return {
      btn_disable:false,
      // 遮罩层
      loading: true,
      // 选中數組
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 顯示搜索条件
      showSearch: true,
      // 总条數
      total: 0,
      // 客戶预约表格數据
      reservationList: [],
      // 弹出层標题
      title: "",
      // 是否顯示弹出层
      open: false,
      // 查询參數
      // 表单參數
      form: {},
      matter_list:[],
      // 表单校验
      rules: {
        email: [
          { required: true, message: "電子郵箱不能為空", trigger: "blur" },
        ],
        customerName: [
          { required: true, message: "客戶姓名不能為空", trigger: "blur" },
        ],
      },
    };
  },
  created() {},
  methods: {
    /** 提交按钮 */
    submitForm() {
      console.log(this.form);
      this.form.bizCustomerReservationItemList = [];
      this.matter_list.map((item, key) => {
        let obj = {
          index: key + 1,
          reservationItem: item,
          remark: "",
        };
        this.form.bizCustomerReservationItemList.push(obj);
      });
      this.$refs["form"].validate((valid) => {
        if (valid) {
          addReservationApply(this.form).then((response) => {
            this.$modal.msgSuccess("预约成功");
            this.btn_disable = true
          });
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        customerId: null,
        customerCode: null,
        customerName: null,
        reservationType: null,
        inviter: null,
        matter: null,
        content: null,
        reservationTime: null,
        receiver: null,
        telphone: null,
        email: null,
        receiverName: null,
        completeTime: null,
        reservationStatus: null,
        billStatus: null,
        billId: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        billCode: null,
        updateBy: null,
      };
      this.resetForm("form");
    },
  },
};
</script>
<style rel="stylesheet/scss" lang="scss">
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../assets/images/login-background.jpg");
  background-size: cover;
}
.container_p {
  background-color: #fff;
  width: 400px;
  height: auto;
  margin: 0 auto;
  padding: 20px 10px;
}
.login-form {
  border-radius: 6px;
  background: #ffffff;
  width: 400px;
  padding: 25px 25px 5px 25px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
.el-login-footer {
  left: 0;
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}
</style>